#include "ioCC2530.h"

#define LED1 P1_0
unsigned int counter = 0;
void initUARTO(void){
  PERCFG =0X00;
  P0SEL = 0X3C;
  U0CSR |= 0X80;
  U0BAUD = 216;
  U0GCR = 10;
  U0UCR |=0X80;
  UTX0IF = 0;
  EA = 1;
}
void initTimer(){
  CLKCONCMD &=0X80;
  T1CTL = 0X0E;
  T1CCTL0 |=0X04;
  T1CC0L = 50000 & 0XFF;
  T1CC0H = (50000 & 0XFF00) >> 8;
  T1IF = 0;
  T1STAT &=~0X01;
  TIMIF &=~0X40;
  IEN1 |=0X02;
  EA = 1;
}
void sendByte(unsigned char c){
  U0DBUF = c;
  while(!UTX0IF);
  UTX0IF = 0;
}
void sendString(unsigned char *str){
      while(*str != '\0'){
        sendByte(*str++);
      }
}
#pragma vector = T1_VECTOR
__interrupt void control(void){
  EA = 0;
  counter++;
  T1STAT &=~0X01;
  EA = 1;
}
void main(void){
  P1DIR |=0X01;
  LED1 = 0;
  initTimer();
  initUARTO();
  while(1){
        if(counter >=15){
          counter = 0;
          LED1 = 1;
          sendString("Hello I am cc2530\n");
          LED1 = 0;
        }
  }
}
